package top.dark.search.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import top.dark.search.service.MallSearchService;
import top.dark.search.vo.SearchParamVo;
import top.dark.search.vo.SearchResultVo;

import javax.servlet.http.HttpServletRequest;

/**
 * Author: Darkn
 * description:
 * Create Time: 2021/3/11 14:47
 */
@Controller
public class SearchController {

    @Autowired
    private MallSearchService mallSearchService;

    @RequestMapping("/list.html")
    public String listPage(SearchParamVo searchParamVo, Model model, HttpServletRequest request) {
        searchParamVo.set_queryString(request.getQueryString());
        SearchResultVo result = mallSearchService.search(searchParamVo);
        model.addAttribute("result", result);
        return "list";
    }

}
